import http from '@/utils/http'

export async function apiGetTodos(args = {}, axiosConfig = {}) {
  const url = '/todos'
  const params = {
    pid: '',
    uid: '',
    ...args,
  }

  const { data = [] } = await http.get(url, params, axiosConfig)
  return data
}

export async function apiAddTodo(args = {}) {
  const url = '/todos'
  const params = {
    pid: '',
    title: '',
    content: '',
    ...args,
  }
  const { data: id = '' } = await http.post(url, params)
  return id
}

export async function apiUpdateTodo(id = '', args = {}) {
  const url = '/todos/' + id
  const params = {
    title: '',
    content: '',
    ...args,
  }
  await http.put(url, params)
  return id
}

export async function apiRemoveTodo(id = '') {
  const url = '/todos/' + id
  await http.delete(url)
  return id
}
